package com.itheima.mp.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.mp.domain.po.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface UserMapper extends BaseMapper<User> {
    /**
     * 根据条件更新余额
     * @param wrapper
     * @param amount
     */
    void updateBalanceByIds(@Param("ew")LambdaQueryWrapper<User> wrapper, @Param("amount")int amount);

    /**
     * 扣减余额
     * @param id
     * @param money
     */
    @Update("update user set balance = balance - #{money} where id = #{id}")
    void deductBalance(@Param ("id")Long id, @Param("money") Integer money);
}
